package com.csdj.server.controller;


import com.csdj.server.pojo.Department;
import com.csdj.server.pojo.RespBean;
import com.csdj.server.service.IDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZouLi
 * @since 2022-12-12
 */
@RestController
@RequestMapping("/system/basic/department")
@Api(tags = "部门控制器")
public class DepartmentController {

    /**
     * 注入 DepartmentService
     **/
    @Autowired
    private IDepartmentService departmentServiceImpl;

    @ApiOperation(value = "获取全部部门信息")
    @GetMapping("/getAllDepartment")
    public List<Department> getAllDepartments() {
        return departmentServiceImpl.getAllDepartmentById(-1);
    }

    @ApiOperation(value = "添加部门")
    @PostMapping("/addDep")
    public RespBean addDep(@RequestBody Department department){
        return departmentServiceImpl.addDepartment(department);
    }

    @ApiOperation(value = "删除部门")
    @DeleteMapping("/delDepartment/{id}")
    public RespBean delDepartment(@PathVariable Integer id){
        return departmentServiceImpl.delDepartment(id);
    }
}
